# 自动获取交易日和假期
import trading_calendars
from datetime import datetime

cn_calendar = trading_calendars.get_calendar('XSHG')
a = cn_calendar.precomputed_holidays

b = [x.to_pydatetime() for x in a]
start = datetime(year=2020, month=1, day=1)
end = datetime(year=2021, month=2, day=1)
PUBLIC_HOLIDAYS = [x for x in b if end >= x >= start]
for d in PUBLIC_HOLIDAYS:
    print(d)
